import java.util.Random;

public class prize {
    public static void main(String[] args) {
        //有{2，3532.。。。。}等奖金
        /*请模拟抽奖，打印每个奖项，如“2元奖金被抽出
        3532元奖金被抽出”*/

        //arr表示奖池
        int[] arr = {2, 3532, 32, 13344, 233};
        //存储抽奖结果
        int[] newArr = new int[arr.length];
        //抽奖
        Random r = new Random();
        //5个奖项
        for (int i = 0; i < 5; ) {
            //获取索引
            int ranodmIndex = r.nextInt(arr.length);
            //获取奖项
            int prize = arr[ranodmIndex];
            //判断奖项是否存在，如果存在则重抽，不在则添加
            boolean flag = contains(newArr, prize);
            if (!flag) {
                newArr[i] = prize;//将抽到的奖项添加
                i++;//移动索引
            }

        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(newArr[i] + " ");
        }
    }
//判断prize在数组中是否存在
    public static boolean contains(int[] arr,int prize) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == prize) {
                return true;
            }
        }
        return false;
    }
}
